﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Diagnostics;

namespace mkuz
{
    public class GeometryUtils
    {
        public static bool CrossSectionAndPerpendicular(Point p1, Point p2, Point p3, out Point crossPoint)
        {

            var p2p1 = p2 - p1;
            var p3p1 = p3 - p1;

            double t = Vector.Multiply(p2p1, p3p1) / p2p1.Length;
            crossPoint = p1 + (Vector.Multiply(p2p1, t)) / p2p1.Length;
            return (t > 0 && t < (p1 - p2).Length);
        }
    }
}
